r2.fn.hide = function(){
	return r2.each(
		this,
		function(){
			this.style.display ='none';
		}
	);
};

r2.fn.show = function() {
	return r2.each(
		this,
		function(){
			this.style.display = '';
		}
	);
};

r2.fn.attribute = function(name,v) {
	return r2.each(
		this,
		function(){
			document.getElementById(this.id).setAttribute(name,v);
			//this.attributes[name] = v;
		}
	);
	
};

r2.fn.property = function(name,v) {
	return r2.each(
		this,
		function(){
			//console.log(this); console.log(name,v);
			this[name] = v;	
		}
	);
	
};




r2.fn.value = function(){
	if(arguments && arguments.length > 0){
		var a = arguments[0];
		return r2.each(
			this,
			function(){
	        	this.value = a;
			}
		);
	}else{
		return this[0].value;
	}
}

//getValues ???

r2.fn.checked = function(){
	if(arguments && arguments.length > 0){
		var a = arguments[0];
		return r2.each(
			this,
			function(){
	        	if(a){this.checked = true;}else{this.checked =false;}
			}
		);

	}else{
		return this[0].checked;
	}	
}


r2.fn.innerHTML = function(v){
	return r2.each(
		this,
		function(){
        	this.innerHTML = v;
		}
	);
};

r2.fn.innerText = function(v){
	return r2.each(
		this,
		function(){
			this.innerText = v;
		}
	);
};

/*
	style ...
*/

r2.fn.bind = function(eventType,fn) {
    return r2.each(this, function() {
        if(this.addEventListener) {
	    this.addEventListener(eventType, fn, false);
        } else if(this.attachEvent) {
	    this.attachEvent('on' + eventType, fn);
	}
	else {
	    this['on' + eventType] = fn;
	}
    });
};

r2.fn.click = function(fn) {return this.bind('click', fn);};
//mu.fn.onhide = function(fn) { return this.bind('onhide', fn); };

r2.fn.click = function(fn) {return this.bind('click', fn);};

r2.fn.mousedown = function(fn) {return this.bind('mousedown', fn);};
r2.fn.mouseup = function(fn) {return this.bind('mouseup', fn);};


r2.fn.touchstart = function(fn) {return this.bind('touchstart', fn);};
r2.fn.touchmove = function(fn) {return this.bind('touchmove', fn);};
r2.fn.touchend = function(fn) {return this.bind('touchend', fn);};
/*
mousedown
mouseup
scroll
touchstart remplace le click
touchmove
touchend
*/


//r2.fn.create = function(type_element,attributes,properties){
r2.fn.create = function(type_element,attributes_properties){
	return r2.each(
		this,
		function(){
			var el = document.createElement(type_element);
			//el.setAttribute("id",id_element);
			this.appendChild(el);

			if(attributes_properties!=undefined){
				//console.log(attributes_properties);
                                var member;
				if(attributes_properties.attributes!=undefined){
					for(member in attributes_properties.attributes){
						el.setAttribute(member,attributes_properties.attributes[member]);
					}
				}

				if(attributes_properties.properties!=undefined){
					for(member in attributes_properties.properties){
						el[member]=attributes_properties.properties[member];
					}
				}

			}

		}
	);
};